define(['../../../../../js/lib/other/sweet-alert'],function() {
    return ['$scope','$location', '$interval','$timeout','$routeParams','bizProxy', function($scope,$location,$interval,$timeout,$routeParams,bizProxy) {
		$scope.$emit("top-show",'true');//顶部显示
    	$scope.$emit('menuTypeLight','mine'); 	//控制底部menu高亮
    	$scope.$emit('bub-menu','true'); 	//隐藏底部menu
    	$scope.$emit('flag-tag','26');//显示底部文字
    	
    	//默认值
    	$scope.isslide_right = false,$scope.isslide_up = false,$scope.allSlt = false;
    	var issueTempData = new Array();
    	
    	if($routeParams.flag != "" && $routeParams.flag != null){
    		getIssueList($routeParams.flag);
    	}
    	
    	//点击状态进入详情
    	$scope.goStatusDet = function(status,caseReleaseId){
    		 if(status == "8"){
    			$scope.$emit("goNext","/issueFailDetail/"+caseReleaseId);
    		}
    	}
    	
    	//点击选中某个
    	$scope.selectalone = function(index){
    		if(issueTempData[index].slt){
    			issueTempData[index].slt = false;
    		}else{
    			issueTempData[index].slt = true;
    		}
    		$scope.issueData = issueTempData;
    	}
    	
    	//点击选中所有
    	$scope.selectAll = function(){
    		if($scope.allSlt){
    			$scope.allSlt = false;
    			issueTempData.forEach(function(value,index){
        			value.slt = false;
        		})
    		}else{
    			$scope.allSlt = true;
    			issueTempData.forEach(function(value,index){
        			value.slt = true;
        		})
    		}
    		$scope.issueData = issueTempData;
    	}
    	
    	//确认删除
    	$scope.confirmDel = function(){
    		var idList = new Array();
    		for(var i=0;i<issueTempData.length;i++){
    			if(issueTempData[i].slt){
    				idList.push(issueTempData[i].caseReleaseId);
    			}
    		}
    		if(idList.length > 0){
    			delIssueCase(idList);
    		}else{
    			$scope.$emit("promptAlertMsg","请选中要删除的案件");
    			$scope.$emit("showCollect",true);
    			$timeout(function(){
    				$scope.$emit("showCollect",false);
    			},transData.promptTime);
    		}
    	}
    	
    	//监听删除点击事件
    	$scope.$on('deleteEvent', function(event,data){
    		if(data){
    			$scope.isslide_right = true,$scope.isslide_up = true;
    		}else{
    			$scope.isslide_right = false,$scope.isslide_up = false;
    		}
        });
    	
    	//删除发布案源
    	function delIssueCase(idList){
    		var headerInfo = {},bizInfo = {};
        	headerInfo.pageNum = '';
        	headerInfo.pageSize = '';
        	headerInfo.sessionId = transData.sessionId;
        	
        	bizInfo.idList = idList;
    		$scope.$emit("loadingChange",true);
    		bizProxy.queryProxyBizData("cancelCaseRelease",headerInfo,bizInfo,
    				function(tempData){//SUCCESS
						$timeout(function(){
							getIssueList($routeParams.flag);
						},0);
		    		},function(data){
		    			if(data != ""){//FAIL
		    				$scope.$emit("loadingChange",false);
							if(data.errorCode == ERROR_CODE.noLogin){
								FIREFLY("", data.errorMsg,"",function(){
										//调用退出登录
										transData.mobileNo = "";
		    							transData.password = "";
		    							transData.sessionId = "";
		    							transData.userType = "";
		    							resultData.loginUserData = "";
		    							$timeout(function(){
		    								$scope.$emit("goNext","/mine");
		    							},0);
								});
							}else{
								$scope.$emit("promptAlertMsg",data.errorMsg);
								$scope.$emit("showCollect",true);
								$timeout(function(){
									$scope.$emit("showCollect",false);
								},transData.promptTime);
							}
		    			}else{
		    				$scope.$emit('loadingChange', false);
		    				$scope.$emit("promptAlertMsg","连接超时");
		    				$scope.$emit("showCollect",true);
		    				$timeout(function(){
		    					$scope.$emit("showCollect",false);
		    				},transData.promptTime);
		    			}
		    		});
    	}
    	
    	//获取发布列表
    	function getIssueList(flag){
    		var headerInfo = {},bizInfo = {};
        	headerInfo.pageNum = '';
        	headerInfo.pageSize = '';
        	headerInfo.sessionId = transData.sessionId;
        	
        	bizInfo.status = flag;
    		$scope.$emit("loadingChangeNav",true);
    		bizProxy.queryProxyBizData('queryCaseReleaseList',headerInfo,bizInfo,
    				function(tempData){//SUCCESS
		    			if(tempData.body != "" && tempData.body != null && tempData.body != "[]"){
							$timeout(function(){
								issueTempData = new Array();
								$scope.$emit("loadingChangeNav",false);
								var myIssueList = JSON.parse(tempData.body);
								for(var i=0;i< myIssueList.length;i++){
									var tempData1 = {
											"status": myIssueList[i].status,
											"caseTopic": myIssueList[i].caseTopic,
											"caseReleaseId":myIssueList[i].caseReleaseId,
											"slt":false
									};
									issueTempData.push(tempData1);
								}
								$scope.issueData = issueTempData;
							},0);
						}else{
							$timeout(function(){
								$scope.$emit("loadingChangeNav",false);
								$scope.$emit('flag-tag','26-1');//显示底部文字
								$scope.issueData = "";
								$scope.promptSlogan = true;
							},0);
						}
		    		},function(data){
		    			if(data != ""){//FAIL
		    				$scope.$emit("loadingChangeNav",false);
							if(data.errorCode == ERROR_CODE.noLogin){
								FIREFLY("", data.errorMsg,"",function(){
										//调用退出登录
										transData.mobileNo = "";
		    							transData.password = "";
		    							transData.sessionId = "";
		    							transData.userType = "";
		    							resultData.loginUserData = "";
		    							$timeout(function(){
		    								$scope.$emit("goNext","/mine");
		    							},0);
								});
							}else{
								$scope.$emit("promptAlertMsg",data.errorMsg);
								$scope.$emit("showCollect",true);
								$timeout(function(){
									$scope.$emit("showCollect",false);
									history.back();
								},transData.promptTime);
							}
		    			}else{
		    				$scope.$emit('loadingChangeNav', false);
		    				$scope.$emit("promptAlertMsg","连接超时");
		    				$scope.$emit("showCollect",true);
		    				$timeout(function(){
		    					$scope.$emit("showCollect",false);
		    					history.back();
		    				},transData.promptTime);
		    			}
		    		});
    	}
    	
    	
        $scope.$apply();
    }];
});